home *** CD-ROM | disk | FTP | other *** search
/ MacFormat España 19 / macformat_19.iso / Shareware / Developers / N Game Library1.1.0E(68k) / Font Sample / Font_Sample.c < prev   
Encoding:
C/C++ Source or Header  |  1996-06-23  |  2.3 KB  |  96 lines  |  [TEXT/CWIE]

  1. /*============================================================
  2.  
  3.                     N_Font sample program
  4.                     
  5. ============================================================*/
  6.  
  7. #include            "N_Library.h"
  8.  
  9. void             DoEvent            (EventRecord *eventPtr);
  10. void             DoError            (Str255 errorString);
  11. WindowPtr     CreateWindow         (Str255 name);
  12.  
  13.  
  14. #define        WindowSizeX        640
  15. #define        WindowSizeY        480
  16.  
  17. short        NewWindowX;
  18. short        NewWindowY;
  19.  
  20. short        Data_Rsrc = 0;
  21.  
  22. WindowPtr    window;
  23.  
  24.  
  25. //counter
  26. long            counter1 = 123456;
  27. long            counter2 = 99999;
  28.  
  29. short        x = -100;
  30. short        x2 = 640;
  31.  
  32. void main(void)
  33. {
  34.     ToolboxInit();
  35.     ColorCheck();
  36.     HideCursor();
  37.     window = CreateWindow("\pN Game Library <Font Sample>");
  38.     N_Window_Set(window,NewWindowX,NewWindowY,WindowSizeX,WindowSizeY);    //set up window
  39.     Open_Resource_File(128,1,&Data_Rsrc);
  40.     N_Sp_Make(640,480);                                                //set up for sprites
  41.     N_Cel_Make(65536);                                                //set up for cel
  42.     N_Font_Init();
  43.     N_Sprite_Set(129,0,14,24,1,11,1,0);                                    //set sprites
  44.     N_Sprite_Set(130,11,12,16,1,13,4,0);
  45.  
  46.     N_Font_Set(0,0,0,0x80000000,0);                                        //set fonts
  47.     N_Font_Set(1,0x80000000+11,0,0x80000000+26+11,0x80000000+37+11);
  48.  
  49.     N_Pict_Draw(128,0,0,(GrafPtr)SP_off,true);                                //draw background
  50.     Close_Resource_File(&Data_Rsrc);
  51.  
  52.     do
  53.     {
  54.         N_Num_Put(counter1,x,80,8,16,0,1,0);                                    //(x,80)ÅAspace16,8segments,fontset0,cel plane  0-
  55.         N_Num_Put(counter2,x,138,8,14,1,1,24);                                //(x,160)ÅAspace14,8segments,fontset1,cel plane  24-
  56.         N_Font_Put("\pN GAME LIBRARY SAMPLE PROGRAM!",x2,180,14,1,1,30);
  57.         counter1++;                                                        //updates counters
  58.         counter2-=64;
  59.         if (counter1 >= 99999999) counter1 = 0;
  60.         if (counter2 <= 0) counter2 = 99999;
  61.     
  62.         x = x+1;                                                            //move
  63.         if (x >= 640) x=-100;
  64.  
  65.         x2-=2;
  66.         if (x2 <= -500) x2=640;
  67.  
  68.     
  69.         N_Cel_Loop(0,0);
  70.     }
  71.     while (!Button());
  72.     ShowCursor();
  73.     ColorRevert();
  74. }
  75.  
  76.  
  77. WindowPtr CreateWindow (Str255 name)
  78. {
  79.     short        centerX,centerY;
  80.     short        windowWidth,windowHeight;
  81.  
  82.     window = GetNewWindow (128,nil,(WindowPtr)-1L );
  83.     centerX  = (qd.screenBits.bounds.right -qd.screenBits.bounds.left)/2;
  84.     centerY  = (qd.screenBits.bounds.bottom -qd.screenBits.bounds.top)/2;
  85.     SetWTitle(window,name);
  86.     MoveWindow(window,NewWindowX=centerX-(WindowSizeX/2),NewWindowY=centerY-(WindowSizeY/2),false);
  87.     SizeWindow(window,WindowSizeX,WindowSizeY,TRUE);
  88.     ShowWindow(window);
  89.     SetPort((GrafPtr)window );
  90.     return (WindowPtr)window;
  91. }
  92.     
  93.  
  94.  
  95.  
  96.